package com.ruoyi.car.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.car.domain.BrowseRecord;
import com.ruoyi.car.service.IBrowseRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 浏览足迹管理Controller
 * 
 * @author yby
 * @date 2025-09-02
 */
@RestController
@RequestMapping("/car/browse")
public class BrowseRecordController extends BaseController
{
    @Autowired
    private IBrowseRecordService browseRecordService;

    /**
     * 查询浏览足迹管理列表
     */
    @PreAuthorize("@ss.hasPermi('car:browse:list')")
    @GetMapping("/list")
    public TableDataInfo list(BrowseRecord browseRecord)
    {
        startPage();
        List<BrowseRecord> list = browseRecordService.selectBrowseRecordList(browseRecord);
        return getDataTable(list);
    }

    /**
     * 导出浏览足迹管理列表
     */
    @PreAuthorize("@ss.hasPermi('car:browse:export')")
    @Log(title = "浏览足迹管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BrowseRecord browseRecord)
    {
        List<BrowseRecord> list = browseRecordService.selectBrowseRecordList(browseRecord);
        ExcelUtil<BrowseRecord> util = new ExcelUtil<BrowseRecord>(BrowseRecord.class);
        util.exportExcel(response, list, "浏览足迹管理数据");
    }

    /**
     * 获取浏览足迹管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('car:browse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(browseRecordService.selectBrowseRecordById(id));
    }

    /**
     * 新增浏览足迹管理
     */
    @PreAuthorize("@ss.hasPermi('car:browse:add')")
    @Log(title = "浏览足迹管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BrowseRecord browseRecord)
    {
        return toAjax(browseRecordService.insertBrowseRecord(browseRecord));
    }

    /**
     * 修改浏览足迹管理
     */
    @PreAuthorize("@ss.hasPermi('car:browse:edit')")
    @Log(title = "浏览足迹管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BrowseRecord browseRecord)
    {
        return toAjax(browseRecordService.updateBrowseRecord(browseRecord));
    }

    /**
     * 删除浏览足迹管理
     */
    @PreAuthorize("@ss.hasPermi('car:browse:remove')")
    @Log(title = "浏览足迹管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(browseRecordService.deleteBrowseRecordByIds(ids));
    }
}
